package com.shuai.mapper;


import com.github.pagehelper.Page;
import com.shuai.annotation.AutoFill;
import com.shuai.dto.ProjectPageQueryDTO;
import com.shuai.entity.Project;
import com.shuai.entity.Project;
import com.shuai.enumeration.OperationType;
import com.shuai.vo.ProjectVO;
import com.shuai.vo.VisualProjectVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProjectMapper {

    /**
     * 根据项目名查询项目
     * @param projectName
     * @return
     */
    @Select("select * from project where projectName = #{projectName}")
    Project getByProjectname(String projectName);

    /**
     * 插入项目数据
     * @param project
     */


    @AutoFill(value = OperationType.INSERT)
    @Insert("insert into  project( project_name,enterprise_id,deadline,status,create_time,update_time)" +
            "value " +
            "( #{projectName}, #{enterpriseId},#{deadline}, #{status}, #{createTime}, #{updateTime})")
    void insert(Project project);


    /**
     * 分页查询
     * */
    Page<Project> pageQuery(ProjectPageQueryDTO projectPageQueryDTO);

    /**
     *更改项目信息
     */
    @AutoFill(value = OperationType.UPDATE)
    void update(Project project);

    /**
     *根据Id查询项目信息
     */
    @Select("select * from project where id = #{id}")
    Project getById(Long id);


    /**
     * 根据id检查密码
     * @param projectId
     * @param password
     * @return
     */
    @Select("select count(*) from project where id = #{projectId} and password = #{password}")
    int checkPassword(Long projectId, String password);


    /**
     * 根据ids批量删除
     * @param ids
     */
    void deleteBatch(List<Long> ids);

    @Delete("delete from project where id = #{id}")
    void deleteByProjectId(Long id);


    Page<VisualProjectVO> visualProjectPageQuery(ProjectPageQueryDTO projectPageQueryDTO, Long userId);
}
